package com.base.common.util;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bean.ObjectMapperUtils;
import org.springframework.beans.BeanUtils;

import java.util.List;

public class IPageUtil {

    public static <T> IPage<T> copy(IPage<?> source, Class<T> tClass) {
        IPage<T> iPage = new Page<T>();
        BeanUtils.copyProperties(source, iPage);
        List<?> records = source.getRecords();
        iPage.setRecords(ObjectMapperUtils.clones(records, tClass));
        return iPage;
    }

}
